package net.zjitc.controller;

import net.zjitc.domain.Category;
import net.zjitc.service.Impl.ServiceImpl;
import net.zjitc.service.Service;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by guo on 2017/11/12.
 */
@WebServlet(name = "UpdateCategoryServlet",urlPatterns = "/updateCategoryServlet")
public class UpdateCategoryServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Category category=new Category();
        try {
            BeanUtils.populate(category,request.getParameterMap());
            Service service=new ServiceImpl();
            int num=service.updateCategory(category);
        } catch (Exception e) {
            e.printStackTrace();
        }
        response.sendRedirect("/shop/categoryServlet");
    }
}
